package org.clockworkmages.games.anno1186.gui;

import java.awt.Graphics;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.clockworkmages.games.anno1186.GameStateService;
import org.clockworkmages.games.anno1186.Injected;
import org.clockworkmages.games.anno1186.model.character.PlayerCharacter;
import org.clockworkmages.games.anno1186.model.character.StatConstants;
import org.clockworkmages.games.anno1186.util.MathUtil;

public class StatsInfoTextPane
		extends InfoTextPane {

	@Injected
	private GameStateService gameStateService;

	private SimpleDateFormat formatter = new SimpleDateFormat(
			"yyyy-MM-dd HH:mm");

	@Override
	public void paint(Graphics g) {
		if (gameStateService != null) {
			PlayerCharacter pc = gameStateService.getGameState().getCharacter();
			int level = pc.getLevel();
			String statsInfo = "\n\n"
					+ formatter.format(new Date(gameStateService.getGameState()
							.getTime()))
					+ "\n\n"
					+ //
					"Health: "
					+ pc.getBaseStatAsInt(StatConstants.HEALTH)
					+ "/"
					+ pc.getDerivateAsInt(StatConstants.D_MAX_HEALTH)
					+ "\n"
					+ //
					"Stamina: "
					+ pc.getBaseStatAsInt(StatConstants.STAMINA)
					+ "/"
					+ pc.getDerivateAsInt(StatConstants.D_MAX_STAMINA)
					+ "\n"
					+ //
					"Fate: "
					+ pc.getBaseStatAsInt(StatConstants.FATE)
					+ "/"
					+ pc.getEffectiveStatAsInt(StatConstants.MAX_FATE)
					+ "\n"
					+ //
					"Level: "
					+ level
					+ " ("
					+ (pc.getExperience() - MathUtil.experienceNeededToLevelUp(level))
					+ "/"
					+ (MathUtil.experienceNeededToLevelUp(level + 1) - MathUtil
							.experienceNeededToLevelUp(level)) + ")" + "\n" + //
					"Gold: " + pc.getGold();

			clearText();
			appendText(statsInfo);
		}
		super.paint(g);
	}
}
